package com.wdy.po;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import com.wdy.util.BasicUtil;

@SuppressWarnings({"unchecked","serial"})
public class Tenement implements Comparable, Serializable {

	private Integer tid;
	private String tname;
	private String ID;
	private Integer age;
	private String sex;
	private String hometown;
	private String telephone;
	private String cellphone;
	private String workUnit;
	private String bank;
	private String account;
	private Date inDate;
	private Date outDate;
	private Set<User> users = new HashSet<User>(0);
	private Set<Building> buildings = new HashSet<Building>();
	private Set<Park> parks = new HashSet<Park>(0);
	private Set<Charge> charges = new HashSet<Charge>(0);
	private Set<Repair> repairs = new HashSet<Repair>(0);
	private Set<Complaint> complaints = new HashSet<Complaint>(0);
	
	public Tenement() {
		super();
	}

	public Tenement(Integer tid, String tname, String id, Integer age,
			String sex, String hometown, String telephone, String cellphone,
			String workUnit, String bank, String account, Date inDate,
			Date outDate, Set<User> users, Set<Building> buildings,
			Set<Park> parks, Set<Charge> charges, Set<Repair> repairs,
			Set<Complaint> complaints) {
		super();
		this.tid = tid;
		this.tname = tname;
		ID = id;
		this.age = age;
		this.sex = sex;
		this.hometown = hometown;
		this.telephone = telephone;
		this.cellphone = cellphone;
		this.workUnit = workUnit;
		this.bank = bank;
		this.account = account;
		this.inDate = inDate;
		this.outDate = outDate;
		this.users = users;
		this.buildings = buildings;
		this.parks = parks;
		this.charges = charges;
		this.repairs = repairs;
		this.complaints = complaints;
	}

	public Integer getTid() {
		return tid;
	}

	public void setTid(Integer tid) {
		this.tid = tid;
	}

	public String getTname() {
		return tname;
	}

	public void setTname(String name) {
		tname = name;
	}

	public String getID() {
		return ID;
	}

	public void setID(String id) {
		ID = id;
	}

	public Integer getAge() {
		return age;
	}

	public void setAge(Integer age) {
		this.age = age;
	}

	public String getSex() {
		return sex;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public String getHometown() {
		return hometown;
	}

	public void setHometown(String hometown) {
		this.hometown = hometown;
	}

	public String getTelephone() {
		return telephone;
	}

	public void setTelephone(String telephone) {
		this.telephone = telephone;
	}

	public String getCellphone() {
		return cellphone;
	}

	public void setCellphone(String cellphone) {
		this.cellphone = cellphone;
	}

	public String getWorkUnit() {
		return workUnit;
	}

	public void setWorkUnit(String workUnit) {
		this.workUnit = workUnit;
	}

	public String getBank() {
		return bank;
	}

	public void setBank(String bank) {
		this.bank = bank;
	}

	public String getAccount() {
		return account;
	}

	public void setAccount(String account) {
		this.account = account;
	}

	public Date getInDate() {
		return inDate;
	}

	public void setInDate(Date inDate) {
		this.inDate = inDate;
	}

	public Date getOutDate() {
		return outDate;
	}

	public void setOutDate(Date outDate) {
		this.outDate = outDate;
	}

	public Set<User> getUsers() {
		return users;
	}

	public void setUsers(Set<User> users) {
		this.users = users;
	}

	public Set<Building> getBuildings() {
		return buildings;
	}

	public void setBuildings(Set<Building> buildings) {
		this.buildings = buildings;
	}

	public Set<Park> getParks() {
		return parks;
	}

	public void setParks(Set<Park> parks) {
		this.parks = parks;
	}

	public Set<Charge> getCharges() {
		return charges;
	}

	public void setCharges(Set<Charge> charges) {
		this.charges = charges;
	}

	public Set<Repair> getRepairs() {
		return repairs;
	}

	public void setRepairs(Set<Repair> repairs) {
		this.repairs = repairs;
	}

	public Set<Complaint> getComplaints() {
		return complaints;
	}

	public void setComplaints(Set<Complaint> complaints) {
		this.complaints = complaints;
	}
/*
	@Override
	public boolean equals(Object o) {
		if(null == o) {
			return false;
		}
		if(o instanceof Tenement){
			Tenement contrastTenement = (Tenement)o;
			Integer contrastTid = contrastTenement.getTid();
			String contrastTname = contrastTenement.getTname();
			if(this.tid.equals(contrastTid) && BasicUtil.isNullOrEmpty(this.tname, contrastTname)){
				return true;
			}
		}
		return false;
	}

	@Override
	public int hashCode() {
		return this.tid.hashCode() * this.tname.hashCode();
	}
*/
	@Override
	public String toString() {
		return this.tname;
	}

	public int compareTo(Object o) {
		Tenement contrastTenement = (Tenement)o;
		Integer contrastTid = contrastTenement.getTid();
		int orignalId = this.tid.intValue();
		int contrastId = contrastTid.intValue();
		return BasicUtil.compare(orignalId, contrastId);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((tid == null) ? 0 : tid.hashCode());
		result = prime * result + ((tname == null) ? 0 : tname.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Tenement))
			return false;
		final Tenement other = (Tenement) obj;
		if (tid == null) {
			if (other.tid != null)
				return false;
		} else if (!tid.equals(other.tid))
			return false;
		if (tname == null) {
			if (other.tname != null)
				return false;
		} else if (!tname.equals(other.tname))
			return false;
		return true;
	}
}
